﻿<Ocean_MVVM:EditFormViewBase
    x:Class="ContactView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:Ocean_MVVM="clr-namespace:Ocean.OceanFramework.MVVM;assembly=OceanFrameworkWPF"
    xmlns:Ocean_WPF="clr-namespace:Ocean.OceanFramework.WPF;assembly=OceanFrameworkWPF">
    <Ocean_MVVM:EditFormViewBase.Resources>

        <Ocean_WPF:ForceReReadConverter x:Key="forceReReadConverter" />
        <Ocean_WPF:FormNotificationErrorMessageConverter x:Key="formNotificationErrorMessageConverter" />

        <ControlTemplate x:Key="validationTemplate">
            <DockPanel>
                <DockPanel.Resources>
                    <Ocean_WPF:ValdiationErrorGetErrorMessageConverter x:Key="valdiationErrorGetErrorMessageConverter" />
                </DockPanel.Resources>
                <TextBlock Margin="5,0,5,0" Foreground="Red" FontSize="16" VerticalAlignment="Center" Text="*" ToolTip="{Binding ElementName=errorAdorner, Path=AdornedElement.(Validation.Errors), Converter={StaticResource valdiationErrorGetErrorMessageConverter}}" />
                <AdornedElementPlaceholder x:Name="errorAdorner" />
            </DockPanel>
        </ControlTemplate>

        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Margin" Value="0,3.5" />
        </Style>
        <Style TargetType="{x:Type Label}">
            <Setter Property="Margin" Value="0,3.5" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Margin" Value="0,3.5" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource validationTemplate}" />
        </Style>

    </Ocean_MVVM:EditFormViewBase.Resources>

    <Border KeyboardNavigation.TabNavigation="Cycle" Margin="11" BorderBrush="LightGray" BorderThickness="1" CornerRadius="10" Padding="10">
        <Grid>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Ocean_WPF:FormNotification Grid.ColumnSpan="2" ErrorHeaderText="{Binding ErrorHeaderText}" WatermarkMessage="{Binding WatermarkMessage}" IsTabStop="False" x:Name="frmNotification" Height="28" Panel.ZIndex="99" AutoCollapseTimeout="2">
                <Ocean_WPF:FormNotification.ErrorMessage>
                    <MultiBinding Converter="{StaticResource formNotificationErrorMessageConverter}">
                        <Binding Path="Contact.Error" />
                        <Binding Path="ErrorMessage" />
                        <Binding Path="UIValidationErrorMessages" />
                    </MultiBinding>
                </Ocean_WPF:FormNotification.ErrorMessage>
            </Ocean_WPF:FormNotification>

            <Label Grid.Column="0" Grid.Row="1" Content="Id" />
            <Label Grid.Column="0" Grid.Row="2" Content="First Name" />
            <Label Grid.Column="0" Grid.Row="3" Content="Last Name" />
            <Label Grid.Column="0" Grid.Row="4" Content="Birthday" />
            <Label Grid.Column="0" Grid.Row="5" Content="Number Of Computers" />
            <Label Grid.Column="0" Grid.Row="6">
                <Hyperlink Focusable="False" Command="{Binding BlogNavigateCommand}">Visit Blog</Hyperlink>
            </Label>
            <Label Grid.Column="0" Grid.Row="7">
                <Hyperlink Focusable="False" Command="{Binding FeedNavigateCommand}">Visit Feed</Hyperlink>
            </Label>
            <Label Grid.Column="0" Grid.Row="8" Content="Comment" />
            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Contact.Id}" />
            <TextBox Grid.Column="1" Grid.Row="2" x:Name="txtFirstName" Text="{Binding Path=Contact.FirstName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, Converter={StaticResource forceReReadConverter}}" Width="150" MaxLength="30" />
            <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=Contact.LastName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, Converter={StaticResource forceReReadConverter}}" Width="150" MaxLength="30" />
            <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=Contact.Birthday, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, TargetNullValue={x:Static sys:String.Empty}, StringFormat=d}" HorizontalAlignment="Left" Width="150" MaxLength="10" />
            <TextBox Grid.Column="1" Grid.Row="5" Text="{Binding Path=Contact.NumberOfComputers, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, StringFormat=F0}" Width="50" MaxLength="2" />
            <TextBox Grid.Column="1" Grid.Row="6" Text="{Binding Path=Contact.BlogURL, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, Converter={StaticResource forceReReadConverter}}" MinWidth="250" HorizontalAlignment="Stretch" MaxLength="100" />
            <TextBox Grid.Column="1" Grid.Row="7" Text="{Binding Path=Contact.FeedURL, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, Converter={StaticResource forceReReadConverter}}" MinWidth="250" HorizontalAlignment="Stretch" MaxLength="100" />
            <TextBox Grid.Column="1" Grid.Row="8" Text="{Binding Path=Contact.Comment, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, Converter={StaticResource forceReReadConverter}}" Width="250" MaxLength="50" />
        </Grid>
    </Border>

</Ocean_MVVM:EditFormViewBase>
